package jee.boot.module.log.local;

import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.boot.ApplicationArguments;
import org.springframework.boot.ApplicationRunner;
import org.springframework.stereotype.Component;

/**
 * 初始化本地日志监控服务
 */
@Component
public class InitLocalLogListener implements ApplicationRunner {

    /**
     * 日志对象
     */
    protected Logger logger = LoggerFactory.getLogger(getClass());

    @Autowired
    private LogThread logThread;
    @Value("${spring.local-log.enable:false}")
    private boolean enable;
    @Override
    public void run(ApplicationArguments args) throws Exception {
        if(enable){
            logger.info("LocalLogListener启动");
            // 开始监听后台任务
            logThread.start();
        }
    }
}
